def is_valid_sequence(s):
  b = []
  c = {")": "(", "}": "{", "]": "[", ">": "<"}
  for char in s:
      if char in c.values():
          b.append(char)
      elif char in c.keys():
          if b == [] or c[char] != b.pop():
              return False
      else:
          return False
  return b == []

a=input()
print(is_valid_sequence(a))